
package com.shop.cloud.mall.api.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.portal.annotation.ApiLogin;
import com.shop.cloud.mall.api.service.DistributionOrderService;
import com.shop.cloud.common.portal.util.ThirdSessionHolder;
import com.shop.cloud.mall.common.entity.DistributionOrder;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 分销订单
 *
 * @author
 * @date 2021-04-30 10:26:30
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/distributionorder")
@Tag(description = "distributionorder", name = "分销订单API")
public class DistributionOrderController {

    private final DistributionOrderService distributionOrderService;

    /**
     * 分销订单分页列表
     * @param page 分页对象
     * @param distributionOrder 分销订单
     * @return
     */
    @Operation(summary = "分销订单分页列表")
    @GetMapping("/page")
	@ApiLogin
    public R getPage(Page page, DistributionOrder distributionOrder) {
    	//查询当前用户为分销员的订单
		distributionOrder.setDistributionUserId(ThirdSessionHolder.getUserId());
        return R.ok(distributionOrderService.page1(page, distributionOrder));
    }

	/**
	 * 获取当前分销员的冻结金额
	 * @return
	 */
	@Operation(summary = "获取当前分销员的冻结金额")
	@GetMapping("/frozenAmount")
	@ApiLogin
	public R getDistributionUserFrozenAmount() {
		return R.ok(distributionOrderService.getDistributionUserFrozenAmount(ThirdSessionHolder.getUserId()));
	}
}
